var ajaxHelper = require("../../utils/ajaxhelp");
const serviceUrl = getApp().globalData.serviceUrl;
let token = wx.getStorageSync('token');

const GetScreenResultByScidAndCustomerId = (scid, customerid) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenResult/GetScreenResultsByScreenIdAndCustomerId", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		scid: scid,
		customerid: customerid
	})
}

const GetScreenResultsCode = (scid, customerid) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenResult/GetScreenResultsCode", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		scid: scid,
		customerid: customerid
	})
}

const CreateScreenResults = (resultList) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenResult/BatchCreateResult", {
		'Authorization': 'Bearer ' + token
	}, "POST", resultList)
}

const UpdateScreenResults = (resultList) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenResult/BatchUpdateResult", {
		'Authorization': 'Bearer ' + token
	}, "POST", resultList)
}

const GetScreenResultByConditions = (scid, customerid) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenResult/GetScreenResultsByScreenIdAndCustomerIdAndContentIds", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		scid: scid,
		customerid: customerid
	})
}

const GetScreenResultByCategory = (scid, customerid, new_categoryid) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenResult/GetScreenResultsByScreenIdAndCustomerIdAndCategoryId", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		scid: scid,
		customerid: customerid,
		new_categoryid: new_categoryid
	})
}

const GetSelectedByScreenIdAndCustomerId = (scid, customerid, new_categoryid) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenResult/GetSelectedByScreenIdAndCustomerId", {
		'Authorization': 'Bearer ' + token
	}, "GET", {
		scid: scid,
		customerid: customerid
	})
}

//为适应校园筛查的潜客问题的新接口
const PostBatchScreenResult = (obj) => {
	token = wx.getStorageSync('token');
	return ajaxHelper.promiseRequst(serviceUrl + "/api/ScreenResult/PostBatchScreenResult", {
		'Authorization': 'Bearer ' + token
	}, "POST", obj)
}

module.exports = {
	GetScreenResultByScidAndCustomerId,
	CreateScreenResults,
	GetScreenResultByConditions,
	GetScreenResultByCategory,
	UpdateScreenResults,
	GetSelectedByScreenIdAndCustomerId,
	GetScreenResultsCode,
	PostBatchScreenResult,
}
